package com.lebang.component;

import com.alibaba.fastjson.JSON;
import com.lebang.common.Constant;
import com.lebang.entity.buss.RecordMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;

import java.util.List;

/**
 * 用户消息推送
 *
 * @Author: hwq
 * @Date: 2019/8/20 9:35
 * @Version 1.0
 */
@Component
public class SendComponent {
    @Autowired
    private RedisClient redisClient;

    public void addToEventToQueue(List<RecordMsg> recordMsgList) {
        try  {
            //redis管道批量写入
            for (RecordMsg recordMsg : recordMsgList) {
                redisClient.lpush(Constant.NEW_RECORD_QUE, JSON.toJSONString(recordMsg));
            }


        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
